// 基于template/src/widgets/{{appEntities}}/{{ctrls@GRID}}-grid/{{spinalCase ctrl.codeName}}-grid-model.ts.hbs生成
import { IGridModel, IParam, isEmpty, VerifyUtil } from '@/core';

function getModel(): IGridModel {
	return {
        cssName: "",        
		aggMode: 'NONE',
		caption: '',
		controlType: 'GRID',
		codeName: 'AddDataGrid',      
		columns: getGridColumns(),
		dataItems: getGridDataItems(),
		dataExport: getDataExport(),
		enableRowEdit: false,
		entityCodeName: 'IBIZCustomer',
		entityLogicName: '客户',
		createDefaultItems: getCreateDefaultItems(),
        updateDefaultItems: getUpdateDefaultItems(),
		name: 'grid',
		noSort: false,
		rules: {
            //	静态值规则
            staticRules: {
		    },
            //	编辑项值规则
            editRules: [
			]
    	},
		showHeader: true,
		sortDir: '',
		sortField: '',
		limit: 10,
		paging: {
			defaultPageSize: 10,
		},
		ctrlMsgModel:[
    ],
		uiEngineModel: [
            {
                name: 'engine_grid',
                triggerType: 'CTRLEVENT',
                logicType: 'APPVIEWENGINE',
                eventNames: 'ROWDBLCLICK;SELECTIONCHANGE;REMOVE;LOAD;BEFORELOAD',
                scriptCode: ``,
                entityCodeName: '',
                logicName:``
            }
    ]
    }
}
//  获取所有表格列模型
function getGridColumns():IParam[] {
  return [
		{
			align: 'left',
			codeName: 'customeruid',
			caption: '客户编号',
			captionLanResTag: 'DEF.LNAME.CUSTOMERUID',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
			dataItemName: 'customeruid',
			dataIndex: 'customeruid',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '客户编号',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'customeruid',
		    minWidth: 150,
		    width: 150,
		    resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'IBIZcustomername',
			caption: '客户名称',
			captionLanResTag: 'DEF.LNAME.IBIZCUSTOMERNAME',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
			dataItemName: 'ibizcustomername',
			dataIndex: 'ibizcustomername',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '客户名称',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'IBIZcustomername',
		    width: 150,
		    minWidth: 150,
		    resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'address',
			caption: '公司地址',
			captionLanResTag: 'DEF.LNAME.ADDRESS',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
			dataItemName: 'address',
			dataIndex: 'address',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '公司地址',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'address',
		    minWidth: 1,
		    width: 1,
		    resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'updateman',
			caption: '更新人',
			captionLanResTag: 'DEF.LNAME.UPDATEMAN',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
		    codeListTag: 'common__SysOperator',
			dataItemName: 'updateman',
			dataIndex: 'updateman',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '更新人',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'updateman',
		    width: 150,
		    minWidth: 150,
		    resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'updatedate',
			caption: '更新时间',
			captionLanResTag: 'DEF.LNAME.UPDATEDATE',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
			dataItemName: 'updatedate',
			dataIndex: 'updatedate',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '更新时间',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'updatedate',
		    width: 150,
		    minWidth: 150,
		    resizable: true,
			stdDataType: 5,
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
		},
  ];
}

//  获取所有表格数据项
function getGridDataItems() {
  return [
    {
			name: 'customeruid',
			codeName: '',
            customCode: false,
			fieldCodeName: 'customeruid',
			fieldName: 'customeruid',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'ibizcustomername',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizcustomername',
			fieldName: 'ibizcustomername',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'address',
			codeName: '',
            customCode: false,
			fieldCodeName: 'address',
			fieldName: 'address',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'updateman',
			codeName: '',
            customCode: false,
			fieldCodeName: 'updateman',
			fieldName: 'updateman',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'updatedate',
			codeName: '',
            customCode: false,
			fieldCodeName: 'updatedate',
			fieldName: 'updatedate',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			dataType: '5'
    },
    {
			name: 'ibizcustomerid',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizcustomerid',
			fieldName: 'ibizcustomerid',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'srfkey',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizcustomerid',
			fieldName: 'ibizcustomerid',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'srfdataaccaction',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizcustomerid',
			fieldName: 'ibizcustomerid',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'srfmajortext',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizcustomername',
			fieldName: 'ibizcustomername',
			valueFormat: '',
			dataType: '25'
    },
  ];
}

function getDataExport() {
	return {
        default: true,
		codeName: 'default',
		enableFront: true,
		fileName: '客户',
		exportItems: [
			{
				name: 'customeruid',
				label: '客户编号',
  				labelLanResTag: 'DEF.LNAME.CUSTOMERUID',
				dataType: 25,
				show: true
			},
			{
				name: 'ibizcustomername',
				label: '客户名称',
  				labelLanResTag: 'DEF.LNAME.IBIZCUSTOMERNAME',
				dataType: 25,
				show: true
			},
			{
				name: 'address',
				label: '公司地址',
  				labelLanResTag: 'DEF.LNAME.ADDRESS',
				dataType: 25,
				show: true
			},
			{
				name: 'updateman',
				label: '更新人',
  				labelLanResTag: 'DEF.LNAME.UPDATEMAN',
				dataType: 25,
				codeListTag: 'common__SysOperator',
				show: true
			},
			{
				name: 'updatedate',
				label: '更新时间',
  				labelLanResTag: 'DEF.LNAME.UPDATEDATE',
				dataType: 5,
				valueFormat: 'YYYY-MM-DD HH:mm:ss',
				show: true
			}
		]
	}
}

function getCreateDefaultItems() {
	return [
	]
}

function getUpdateDefaultItems() {
	return [
	];
}

export const model = getModel();